﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MyAdManager : MySingleton<MyAdManager>
{
    public void MyShowBanner()
    {
        if (!AdManager.Instance.ShieldAddress)
        {
            AdManager.Instance.ShowBanner();
        }
    }
    public void MyShowNative(float delay = 1.0f)
    {
        if (!AdManager.Instance.ShieldAddress)
        {
            AdManager.Instance.ShowNative(delay);
        }
    }
    public void MyShowStartBox(Action callBack = null)
    {
        if (!AdManager.Instance.ShieldAddress)
        {
            if (!AdManager.IsOpenWorkTimeShield)
                CheckTouch.Show(callBack);
            else
            {
                callBack?.Invoke();
            }
        }
        else
        {
            callBack?.Invoke();
        }
    }
    public void MyShowEndBox(Action callBack = null)
    {
        if (!AdManager.Instance.ShieldAddress)
        {
            if (!AdManager.IsOpenWorkTimeShield)
                StartCoroutine(showbox(callBack));
            else
            {
                AdManager.Instance.ShowNative(0);
                callBack?.Invoke();
            }
        }
        else
        {
            AdManager.Instance.ShowNative(0);
            callBack?.Invoke();
        }
    }
    IEnumerator showbox(Action callBack = null)
    {
        yield return new WaitForSeconds(0f);
        CheckTouch.Show(callBack);
    }
}
